    <?php if (count($customFields)): ?>
    <div id="custom-fields" class="container">
        <fieldset>
            <legend><?php echo Translator::translate('Custom fields'); ?></legend>
            <input type="hidden" name="numberOfCustomFields" value="<?php echo count($customFields); ?>" />
            <?php foreach ($customFields as $i => $field): ?>
            <div class="custom-field" id="custom-field-<?php echo preg_replace('/\[(.*)\]/', '-$1', $field->name); ?>">
                <?php
                    $displayType = $customFields[$i]->valueDisplayType;
                    if ($displayType == 1): ?>
                <div class="field text">
                    <?php
                        HtmlBinder::labelFor($customFields[$i], 'value', $customFields[$i]->name);
                        HtmlBinder::textBoxFor($customFields[$i], 'value');
                        HtmlBinder::validationMessagesFor($customFields[$i], 'value');
                    ?>
                </div>
                <?php elseif ($displayType == 2): ?>
                <div class="field textarea">
                    <?php
                        HtmlBinder::labelFor($customFields[$i], 'value', $customFields[$i]->name);
                        HtmlBinder::textareaFor($customFields[$i], 'value');
                        HtmlBinder::validationMessagesFor($customFields[$i], 'value');
                    ?>
                </div>
                <?php elseif ($displayType == 3): ?>
                <div class="field text date">
                    <?php
                        HtmlBinder::labelFor($customFields[$i], 'value', $customFields[$i]->name);
                        HtmlBinder::textBoxFor($customFields[$i], 'value');
                        HtmlBinder::validationMessagesFor($customFields[$i], 'value');
                    ?>
                </div>
                <?php endif; ?>
                <button name="delete-custom-field" type="submit" title="<?php echo Translator::translate("Deletes the custom field '%s'", $customFields[$i]->name); ?>" value="<?php echo $customFields[$i]->id; ?>">
                    <span>Delete field</span>
                </button>
            </div>
            <?php endforeach; ?>
        </fieldset>
    </div>
    <?php endif; ?>
    <div id="add-custom-field" class="container">
        <fieldset class="custom-field">
            <legend><?php echo Translator::translate('Add custom field'); ?></legend>
            <div class="field text">
                <?php
                    HtmlBinder::labelFor($model->newCustomField, 'name');
                    HtmlBinder::textBoxFor($model->newCustomField, 'name');
                    HtmlBinder::validationMessagesFor($model->newCustomField, 'name');
                ?>
            </div>
            <div class="field select">
                <?php
                    HtmlBinder::labelFor($model->newCustomField, 'valueDisplayType');
                    HtmlBinder::selectFor($model->newCustomField, 'valueDisplayType', array("1" => "Short text (single line)", "2" => "Long text (multiple lines)", "3" => "Date"));
                    HtmlBinder::validationMessagesFor($model->newCustomField, 'valueDisplayType');
                ?>
            </div>
            <button name="add-custom-field" value="add-custom-field-submit" type="submit">
                <span><?php echo Translator::translate('Add custom field'); ?></span>
            </button>
        </fieldset>
    </div>